/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package persistence;

import java.util.List;
import model.FilmMaatschappij;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author Matthy & Jelle
 */
public class FilmMaatschappijService extends AbstractService{

  public List<FilmMaatschappij> getList() {
    List<FilmMaatschappij> maatschappijen;
    Session session = HibernateUtil.getSessionFactory().getCurrentSession();
    session.beginTransaction();
    Query query = session.createQuery("from FilmMaatschappij");
    maatschappijen = query.list();
    session.getTransaction().commit();
    return maatschappijen;
  }

  @Override
  public boolean validate(Object o) {
    FilmMaatschappij fm = (FilmMaatschappij)o;
    if (fm.getNaam().isEmpty() || fm.getNaam() == null) {
      return false;
    }
    return true;
  }



}
